package com.gjy.annotation;

import com.gjy.annotation.anno.Author;
import com.gjy.annotation.anno.Authors;
import org.junit.jupiter.api.Test;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2023-03-31 14:56:44
 */
public class AuthorTest {

    @Test
    public void test1() {
        Author author = Book.class.getDeclaredAnnotation(Author.class);
        System.out.println("author.name() = " + author.name());
    }

    @Test
    public void test2() {
        Authors authors = Book2.class.getDeclaredAnnotation(Authors.class);
        for (Author author : authors.value()) {
            System.out.println("author.name() = " + author.name());
        }
    }

    @Test
    public void test3() {
//        Author author = Book3.class.getDeclaredAnnotation(Author.class);
//        System.out.println("author = " + author);

        Author[] authors = Book3.class.getDeclaredAnnotationsByType(Author.class);
        for (Author author : authors) {
            System.out.println("author = " + author);
        }
    }

    @Author(name = "Hello0")
    @Author(name = "Hello2")
    @Author(name = "Hello3")
    private static final class Book3 {

    }

    @Authors(value = {
            @Author(name = "Hello0"),
            @Author(name = "Hello2"),
            @Author(name = "Hello3")
    })
    private static final class Book2 {

    }

    @Author(name = "hello")
    private static final class Book {

    }
}
